﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zatify.Domain.Data
{
    public enum PromotionStatus
    {
        Pending = 1,
        Active = 2,
        Complete = 3
    }

    public partial class Promotion
    {
        private Business _business;

        public PromotionStatus Status
        {
            get
            {
                if (this.StatusCode == "PEN")
                    return PromotionStatus.Pending;
                else if (this.StatusCode == "ACT")
                    return PromotionStatus.Active;
                else
                    return PromotionStatus.Complete;
            }
        }

        public Business Business
        {
            get
            {
                if (_business == null)
                {
                    Zatify.Domain.Concrete.ZatifyRepository _db = new Zatify.Domain.Concrete.ZatifyRepository();
                    _business = _db.BusinessGetById(this.BusinessId);
                    _business.BusinessHours = _db.BusinessGetBusinessHours(this.BusinessId);
                }

                return _business;
            }
        }

        public IEnumerable<Category> Categories
        {
            get
            {
                Zatify.Domain.Concrete.ZatifyRepository _db = new Zatify.Domain.Concrete.ZatifyRepository();
                return _db.PromotionGetCategoriesByPromotionId(this.PromotionId);
            }
        }

        public ProximityRadius ProximityRadius
        {
            get
            {
                Zatify.Domain.Concrete.ZatifyRepository _db = new Zatify.Domain.Concrete.ZatifyRepository();
                return _db.ProximityRadiusGetById(this.ProximityRadiusId.Value);
            }
        }
    }
}
